/* 任务队列 */

#include<queue>
#include<string>
#include<iostream>
using namespace std;

struct TTask
{
	string name;
	int totalTime;
};

int main(void)
{
	constexpr int N = 5;
	TTask tasks[] = {
		{"p1", 150},
		{"p2", 80},
		{"p3", 200},
		{"p4", 350},
		{"p5", 20}
	};
	int timeUnit = 100;

	queue<TTask> queTask;
	for (auto t : tasks)
	{
		queTask.push(t);
	}

	int curTime = 0;
	while (!queTask.empty())
	{
		TTask t = queTask.front();
		queTask.pop();

		if (t.totalTime <= timeUnit)
		{
			curTime += t.totalTime;
			cout<< t.name << " " << curTime <<endl;
		}
		else
		{
			curTime += timeUnit;
			t.totalTime -= timeUnit;
			queTask.push(t);
		}
	}

	return 0;
}
